﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

/// <summary>
/// Summary description for CategoryData
/// </summary>
public class CategoryData
{
	public CategoryData()
	{
		//
		// TODO: Add constructor logic here
		//
	}
    public bool add(CategoriesEntities item)
    {
        bool flat = false;
        string[] pamamaters = { "@name", "@prority", "@display" };
        string[] values = { item._name,item._priority.ToString(),item._display};
        if (Database.getExecProcedure("InsertCategory", pamamaters, values) > 0)
        {
            flat = true;
        }
        else
        {
            flat = false;
        }
        return flat;
    }

    public bool edit(CategoriesEntities item)
    {
        bool flat = false;
        string[] pamamaters = {"@id", "@name", "@prority", "@display" };
        string[] values = {item._id.ToString(), item._name, item._priority.ToString(), item._display };
        if (Database.getExecProcedure("EditCategory", pamamaters, values) > 0)
        {
            flat = true;
        }
        else
        {
            flat = false;
        }
        return flat;
    }

    public bool delete(int id)
    {
        bool flat = false;
        string[] pamamaters = { "@id" };
        string[] values = { id.ToString()};
        if (Database.getExecProcedure("DeleteCategory", pamamaters, values) > 0)
        {
            flat = true;
        }
        else
        {
            flat = false;
        }
        return flat;
    }

    public DataTable getCategory(int id)
    {
        return Database.getTable("exec GetCategory '"+id.ToString()+"'");
    }
}
